package com.bs.bsacexj.web.controller;


import com.alibaba.fastjson2.JSONObject;
import com.bs.bsacexj.common.core.domain.AjaxResult;
import com.bs.bsacexj.service.IEventCallBackService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author Administrator
 */
@RestController
@RequestMapping("/event/callback")
public class EventCallbackController {
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());


    @Autowired
   private final IEventCallBackService eventCallBackService;

    public EventCallbackController(IEventCallBackService eventCallBackService) {
        this.eventCallBackService = eventCallBackService;
    }

    @PostMapping("/face")
    public AjaxResult faceCallback(@RequestBody Object eventParam) throws Exception {
        logger.info("收到海康刷脸事件回调{}",JSONObject.toJSONString(eventParam));
       boolean result= eventCallBackService.personFaceCallback(eventParam);
        return  result? AjaxResult.success():AjaxResult.error("操作失败");
    }
    @PostMapping("/card")
    public AjaxResult cardCallback(@RequestBody Object eventParam) throws Exception {
        logger.info("收到海康刷卡事件回调{}",JSONObject.toJSONString(eventParam));
        boolean result= eventCallBackService.personCardCallback(eventParam);
        return  result? AjaxResult.success():AjaxResult.error("操作失败");
    }
}
